package org.fxml.helpers {
	import flash.display.Sprite;

	/**
	 * @author jordandoczy
	 */
	public class SpriteBuilder extends AbstractBuilder{

		protected const WIDTH:String = "width";
		protected const HEIGHT:String = "height";
		
		public function SpriteBuilder(baseBuilder:IBuilder){
			super(baseBuilder);
		}
		
		public override function setProperty(instance:Object, property:String, value:*):void{
			switch(property){
				case WIDTH:
					addBoundingBox(Sprite(instance), Number(value), Sprite(instance).height);
				break;
				case HEIGHT:
					addBoundingBox(Sprite(instance), Sprite(instance).width, Number(value));
				break;
				default: _baseBuilder.setProperty(instance, property, value);
			}
		}
		
		public function addBoundingBox(instance:Sprite, width:Number, height:Number):void{
			instance.graphics.beginFill(0x000000, 0);
			instance.graphics.drawRect(0, 0, width, height);
			instance.graphics.endFill();
		}
	}
}
